package com.hup.utils.commons;

import com.hup.utils.commons.exception.AppCommonException;

import java.io.File;

/**
 * @author hugan
 * @date 2019/8/3
 */
public class AssertApp {

    public static void isTrue(boolean b, String msg) {
        if (!b) throw new AppCommonException(msg);
    }

    public static void notEmptyString(String str, String msg) {
        if (TextUtil.isBlank(str)) throw new AppCommonException(msg);
    }

    public static void exists(String path) {
        if (path == null || !new File(path).exists()) {
            throw new AppCommonException("找不到文件:[" + path + "]");
        }
    }

    public static void exists(String path, String desc) {
        if (path == null || !new File(path).exists()) {
            throw new AppCommonException("找不到[" + desc + "]文件:[" + path + "]");
        }
    }

    public static void notNull(Object o, String msg) {
        if (o == null) {
            throw new AppCommonException(msg);
        }
    }
}
